package com.myexample.hmsdemo.presenter;

import android.content.Context;
import android.content.Intent;

import com.huawei.hms.support.account.result.AuthAccount;
import com.myexample.hmsdemo.model.ILogin;
import com.myexample.hmsdemo.model.impl.HuaweiLogin;
import com.myexample.hmsdemo.view.IMainView;

public class MyPresenter {
    private final ILogin iLogin;
    private IMainView view;
    public final static int LOGIN_CODE=10000;
    private AuthAccount authAccount;
    public MyPresenter(){
        iLogin=new HuaweiLogin();
    }
    public void setIMainView(IMainView view){
        this.view=view;
    }
    public Intent getHuaweiLogin(Context context){
        return iLogin.getIntent(context);
    }
    public void setAccount(Intent data){
        authAccount=iLogin.getAccount(data);
    }

    public boolean isLogin(){
        return authAccount != null;
    }

    public void logout(){
        iLogin.logout();
        showShortToast("登出成功");
    }
    public void showShortToast(String text){
        view.showShortToast(text);
    }
    public void showLongToast(String text){
        view.showLongToast(text);
    }

}
